import Ember from 'ember';
import BaseBusiness from '../base-business';

export default BaseBusiness.extend({
  queryParams: {
      id: {
          refreshModel: true
      },
      editMode: {
          refreshModel: true
      },
  },
  header_title: "评估模板信息",
  model() {
    return {};
  },
  setupController(controller, model){
    var _self = this;
    this._super(controller, model);
    var editMode=this.getCurrentController().get('editMode');
    var id=this.getCurrentController().get('id');
    controller.set('curQuestion','');
    controller.set('curAnswer','');
    if(editMode=='edit'){//点击列表进入的详情页
      controller.set('detailEdit',false);
      this.store.findRecord('evaluatemodel',id).then(function(evaInfo){
        controller.set('evaInfo',evaInfo);
        //判断评估方式，选择显示页面
        if(controller.get('evaInfo.type.typename')==='分数评测'){
          controller.set('score',true);
        }
      });

    }else{//点击新增进入的编辑页
      controller.set('detailEdit',true);
      this.store.findRecord('evaluatemodel',id).then(function(evaInfo){
        controller.set('evaInfo',evaInfo);
      });

    }
    this.store.query('evaluatequestion',{sort:{seq:'desc'},filter:{model:{id:id}}}).then(function(questionList){
      controller.set('questionList',questionList);
    });
    this.store.query('customerserviceitem',{}).then(
      function(serviceList){
        controller.set("allServiceList",serviceList);
      }
    );


  }
});
